module PriceHelper

  #Creates the boilerplate for creating a price field
  #noinspection RubyUnnecessaryReturn
  def create_price_field(field_name)
    return ( {
                :class_name => 'Money',
                :mapping => [field_name, "cents"],
                :constructor => Proc.new { |cents, currency| Money.new(cents || 0, currency || Money.default_currency) },
                :converter => Proc.new { |value| value.respond_to?(:to_money) ? value.to_money : Money.empty }

    })
  end
end
